/*
 * Copyright (C) 2015 yixun All Rights Reserved.
 * 
 * SaleStatusEnum.java
 */
package com.yixun.qfbao.xf.model.enums;

import com.yixun.common.utils.EnumUtil;
import org.apache.commons.lang.StringUtils;

import java.io.Serializable;

/**
 * @version 1.00
 */
public enum CheckSwitchEnum implements Serializable {
	CLOSED("0", "关闭", null),
	OPEN("1", "开启", null),
	;

	private final String no;
	private final String des;
	private final Enum parent;

	static {
		EnumUtil.ENUMS_TO_VIEW.put("check_switch", CheckSwitchEnum.values());
	}

	/**
	 * 私有构造函数
	 *
	 * @param des
	 * @param parent
	 */
	CheckSwitchEnum(String no, String des, Enum parent) {
		this.no = no;
		this.des = des;
		this.parent = parent;
	}

	/**
	 * @return Returns the no.
	 */
	public String getNo() {
		return no;
	}

	/**
	 * @return Returns the des.
	 */
	public String getDes() {
		return des;
	}

	/**
	 * @return Returns the parent.
	 */
	public Enum getParent() {
		return parent;
	}

	/**
	 * 通过枚举<code>des</code>获得枚举
	 * 
	 * @param des
	 * @return
	 */
	public static CheckSwitchEnum getByDescription(String des) {
		if (StringUtils.isBlank(des)) {
			return null;
		}
		for (CheckSwitchEnum menum : values()) {
			if (menum.getDes().equals(des)) {
				return menum;
			}
		}
		return null;
	}

	public static CheckSwitchEnum getByNo(String no) {
		if (StringUtils.isBlank(no)) {
			return null;
		}
		for (CheckSwitchEnum menum : values()) {
			if (menum.getNo().equals(no)) {
				return menum;
			}
		}
		return null;
	}
}
